package com.stox.charting.ui.swing.model.indicator;

import java.util.ArrayList;
import java.util.List;

import com.stox.charting.ui.swing.model.Chart;
import com.stox.charting.ui.swing.model.ChartModel;
import com.stox.charting.ui.swing.model.Viewport;
import com.stox.charting.ui.swing.model.uiUnit.BarUiUnit;

public class BarChartModel extends ChartModel<Double> {
	
	private final BarViewport barViewport;
	
	public BarChartModel(Chart<Double> chart) {
		super(chart);
		this.barViewport = new BarViewport(this);
	}

	@Override
	public void constructUiUnits() {
		List<Double> data = getData();
		if(data != null && !data.isEmpty()){
			List<BarUiUnit> uiUnits = new ArrayList<BarUiUnit>(data.size());
			for(int i = 0; i < data.size(); i++){
				uiUnits.add(new BarUiUnit(this, i));
			}
			getViewport().setUiUnits(uiUnits);
		}
	}

	@Override
	public Viewport<Double> getViewport() {
		return barViewport;
	}
	

}
